<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>软工综合信息系统-首页</title>
		<script src="./js/jquery-2.2.4.min.js"></script>
		<script src="./bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="./bootstrap-3.3.7-dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="http://at.alicdn.com/t/font_1621632_vkilb9w47k.css">
		<script type="text/javascript" charset="utf-8" src="./ueditor_1.4.3.3/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="./ueditor_1.4.3.3/ueditor.all.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="./ueditor_1.4.3.3/lang/zh-cn/zh-cn.js"></script>
		<script type="text/javascript" charset="utf-8" src="./js/JQSession.js"></script>
		<script src="./js/public.js"></script>
		<script src="./laydate/laydate.js"></script>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			
			textarea {
				resize: none;
			}
			
			a {
				cursor: pointer;
			}
			
			li {
				list-style: none;
			}
			
			.mynav {
				margin-left: 5%;
			}
			
			.mynav .myul {
				width: 100%;
				height: 100%;
				display: flex;
				align-items: stretch;
				flex-direction: column;
				list-style: none;
			}
			
			.myul li a {
				padding: 10px 80px;
			}
			
			.mynav-header {
				height: 40px;
				padding: 20px 15px 20px 15px;
				float: right;
			}
			
			.mybody {
				padding: 0 20px;
			}
			
			.mylogin {
				font-size: 16px;
				float: right;
			}
			
			.mylogin {
				font-size: 16px;
				float: right;
			}
			
			.pager a {
				margin: 0 5px;
			}
			
			.table {
				table-layout: fixed;
			}
			
			.table td {
				width: 100%;
				word-break: keep-all;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			
			#mybody-nav {
				padding: 0 20px;
				line-height: 60px;
				height: 60px;
				margin-bottom: 30px;
			}
			
			.panel-heading {
				padding: 10px 95px;
			}
			
			.panel-body {
				padding: 0;
			}
			
			.panel-group {
				margin-bottom: 0;
			}
			
			.panel {
				margin-bottom: 0;
			}
			/* 通过改变这三个display来调整不同的导航 */
			
			#student {
				/* display: none; */
				text-align: center;
			}
			
			#teacher {
				/*display: none;*/
				text-align: center;
			}
			
			#admin {
				/*display: none;*/
				text-align: center;
			}
			
			#cAdmin {
				/*display: none;*/
				text-align: center;
			}
			
			.sdimg {
				width: 62px;
				height: 62px;
				vertical-align: middle;
				cursor: pointer;
			}
			
			.sdimg: hover {
				background-color: #C3C3C3;
			}
			
			.sdimg img {
				width: 34px;
				height: 34px;
				margin-top: 14px;
				margin-left: 14px;
				border-radius: 34px;
			}
			
			.hotTOP10 {
				overflow: hidden;
				margin-top: 10px;
				border: 1px solid lightgray;
				border-radius: 6px;
				margin-bottom: 40px;
			}
			
			.hotTOP10-p {
				text-align: center;
				font-size: 16px;
				font-weight: 600;
				border-bottom: 1px solid #C3C3C3;
				height: 40px;
				line-height: 2.2;
			}
			
			.hotTOP10-ul-li {
				cursor: pointer;
				width: 288px;
				height: 70px;
				padding-top: 4px;
				padding-bottom: 4px;
				border-bottom: 1px solid lightgray;
			}
			
			.hotTOP10-ul-li:hover {
				background-color: gainsboro;
			}
			
			.hotTOP10-ul-li-h5 {
				max-width: 275px;
				color: #333;
				font-weight: 600;
				margin-left: 6px;
				margin-top: 4px;
				margin-bottom: 4px;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			
			.hotTOP10-ul-li-h6 {
				max-height: 20px;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			
			.hotTOP10-ul-li-h6 p {
				max-width: 210px;
				color: gray;
				font-size: 14px;
				margin-top: 4px;
				margin-left: 8px;
				float: left;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			
			.hotTOP10-ul-li-span {
				color: #337ab7;
				font-size: 13px;
				float: right;
				margin-top: -24px;
				margin-right: 6px;
			}
			
			.h4_change {
				display: block;
				width: 288px;
				height: 36px;
				line-height: 2.2;
			}
			
			.panel-heading {
				padding: 0;
			}
			
			.nav-li li a {
				line-height: 2;
				font-size: 16px;
			}
			
			.nav-li li:hover {
				background-color: #C3C3C3;
			}
			
			.nav-a {
				line-height: 1.5;
				font-size: 20px;
			}
		</style>
	</head>

	<body>
		<div class="container-fluid">
			<div class="row">
				<nav class="navbar navbar-default navbar-static-top">
					<div class="container">
						<ul class="nav navbar-nav navbar-left">
							<a class="navbar-brand nav-a" href="./home.html">软工综合信息系统</a>
						</ul>
						<ul class="nav navbar-nav navbar-right nav-li">
							<li>
								<a href="#" id="loginout1"><span class="iconfont icon-084tuichu"></span>退出</a>
							</li>
							<li id="article_work" index="addArticle">
								<a href="#"><span class="iconfont icon-combinedshapecopy2"></span>写文章</a>
							</li>
							<li index="student" id="student_data">
								<a href="#">个人中心</a>
							</li>
							<li index="cstudent" class="sdimg"><img src="./img/DefaultHead.jpg" alt="头像" class="img-circle" id="img_src"></li>
						</ul>
					</div>
				</nav>
				<div class=" col-xs-12 col-sm-12 col-md-4 col-lg-4 collapse navbar-collapse mynav" id="bs-example-navbar-collapse-1" role="navigation">
					<div id="nav-left">
						<div id="student">
							<div class="panel-group" id="accordion11" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingOne11">
										<h4 class="panel-title h4_change">
                                        <li role="button" data-toggle="collapse" data-parent="#accordion11" href="#collapseOne11" aria-expanded="true" aria-controls="collapseOne11">
                                                        站内通知
                                        </li>
                                    </h4>
									</div>
									<div id="collapseOne11" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne11">
										<div class="panel-body">
											<ul class="nav nav-pills dropdown-toggle myul" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" class="active" index="message">
													<a href="#">专业通知</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
							<div class="panel-group" id="accordion1" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingOne">
										<h4 class="panel-title h4_change">
                                        <li role="button" data-toggle="collapse" data-parent="#accordion1" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                                        毕业设计
                                        </li>
                                    </h4>
									</div>
									<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
										<div class="panel-body">
											<ul class="nav nav-pills dropdown-toggle myul" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="campus">
													<a href="#">校内毕设选题</a>
												</li>
												<li role="presentation" index="afterschool">
													<a href="#">校外毕设选题</a>
												</li>
												<li role="presentation" id="completionphase" index="completionphase" style="display: none;">
													<a href="#">上传毕设资料</a>
												</li>
												<li role="presentation" index="studentlook">
													<a href="#">我的毕设状态</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
							<div class="panel-group" id="accordion2" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingTwo">
										<h4 class="panel-title h4_change">
                                    <li class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                                                文章模块
                                    </li>
                                </h4>
									</div>
									<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
										<div class="panel-body">
											<!-- 这里放通知的二级导航 -->
											<ul class="nav nav-pills dropdown-toggle myul " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="articlelist" id="article_full">
													<a href="#">站内文章</a>
												</li>
												<li role="presentation" index="articlelist" id="article_my">
													<a href="#">维护文章</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
							<div class="panel-group" id="accordion3" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingThree">
										<h4 class="panel-title h4_change">
                                    <li class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion3" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
                                                活动模块
                                    </li>
                                </h4>
									</div>
									<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
										<div class="panel-body">
											<!-- 这里放报名的二级导航 -->
											<ul class="nav nav-pills dropdown-toggle myul " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="studentActivity">
													<a href="#">站内活动</a>
												</li>
												<li role="presentation" index="studentAuditstatus">
													<a href="#">报名记录</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div id="teacher">
							<div class="panel-group" id="accordion4" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingOne1">
										<h4 class="panel-title h4_change">
                                        <li role="button" data-toggle="collapse" data-parent="#accordion4" href="#collapseOne1" aria-expanded="true" aria-controls="collapseOne1">
                                                毕业设计
                                        </li>
                                    </h4>
									</div>
									<div id="collapseOne1" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne1">
										<div class="panel-body">
											<ul class="nav nav-pills dropdown-toggle myul " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="teachercampus" class="active">
													<a href="#">毕设选题维护</a>
												</li>
												<li role="presentation" index="teacherlook">
													<a href="#">查看毕设进度</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
							<div class="panel-group" id="accordion5" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="heading2">
										<h4 class="panel-title h4_change">
                                    <li class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion5" href="#collapse2" aria-expanded="false" aria-controls="collapse2">
                                                活动模块
                                    </li>
                                </h4>
									</div>
									<div id="collapse2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading2">
										<div class="panel-body">
											<!-- 这里放通知的二级导航 -->
											<ul class="nav nav-pills dropdown-toggle myul " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="teacherActivities">
													<a href="#">活动维护</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div id="admin">
							<div class="panel-group" id="accordion6" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingOne3">
										<h4 class="panel-title h4_change">
                                        <li role="button" data-toggle="collapse" data-parent="#accordion6" href="#collapseOne3" aria-expanded="false" aria-controls="collapseOne3">
                                                综合信息管理
                                        </li>
                                    </h4>
									</div>
									<div id="collapseOne3" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne3">
										<div class="panel-body">
											<ul class="nav nav-pills dropdown-toggle myul " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="messageamend" class="active">
													<a href="#">通知管理</a>
												</li>
												<li role="presentation" index="adminsearch">
													<a href="#">账号维护</a>
												</li>
												<li role="presentation" index="gongsi">
													<a href="#">公司维护</a>
												</li>
												<li role="presentation" index="stadycost">
													<a href="#">学费维护</a>
												</li>
												<li role="presentation" index="tianjiashixijilu">
													<a href="#">实习记录维护</a>
												</li>
												<li role="presentation" index="adminStage">
													<a href="#">毕设阶段维护</a>
												</li>
												<li role="presentation" index="adminEmail">
													<a href="#">定时邮箱维护</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div id="cAdmin">
							<div class="panel-group" id="accordion7" role="tablist" aria-multiselectable="true">
								<div class="panel panel-default">
									<div class="panel-heading" role="tab" id="headingOne4">
										<h4 class="panel-title h4_change">
                                        <li role="button" data-toggle="collapse" data-parent="#accordion7" href="#collapseOne4" aria-expanded="false" aria-controls="collapseOne4">
                                                综合信息管理
                                        </li>
                                    </h4>
									</div>
									<div id="collapseOne4" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne4">
										<div class="panel-body">
											<ul class="nav nav-pills dropdown-toggle myul " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
												<li role="presentation" index="cAdminCompany" class="active">
													<a href="#">公司信息</a>
												</li>
												<li role="presentation" index="cAdminResumeList">
													<a href="#">学生简历</a>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="hotTOP10">
						<p class="hotTOP10-p">热门文章</p>
						<ul class="hotTOP10-ul" id="hotTOP10">

						</ul>
					</div>
				</div>
				<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 mybody">
					<div class="center">

					</div>
				</div>
			</div>
		</div>
		<script>
			function is_putg() {
				$.ajax({
					xhrFields: {
						withCredentials: true
					},
					type: 'get',
					url: getFullURL('user/bstp-status'),
					data: {},
					dataType: 'json',
					success: function(data) {
						console.log(data)
						if(data.bsStatus != 2) {
							$('#completionphase').css("display", "none");
						} else {
							$('#completionphase').css("display", "block");
						}
					},
					error: function(err) {
						alert("请求异常，请重新登录！", function() {
							$(location).attr('href', './login.html');
						})
					}
				})
			}

			//全局变量，保存学号或教师号
			var user = '';

			$(function() { // 初始化内容
				var flag = $.session.get("shenfen");

				if(flag == "user") {
					$('.center').load('./message.html')
					$('#student').css('display', 'block');
					$('#teacher').css('display', 'none');
					$('#admin').css('display', 'none');
					$('#cAdmin').css('display', 'none');

					user = $.session.get("sno");
					is_putg()
				} else if(flag == "teacher") {
					$('#student').css('display', 'none');
					$('#teacher').css('display', 'block');
					$('#admin').css('display', 'none');
					$('#cAdmin').css('display', 'none');

					$('.sdimg').attr("index", "student");
					$('#article_work').css('display', 'none');
					user = $.session.get("tno");
					
					$.session.set("home_path","teachercampus");
				} else if(flag == "admin") {
					$('#student').css('display', 'none');
					$('#teacher').css('display', 'none');
					$('#admin').css('display', 'block');
					$('#cAdmin').css('display', 'none');

					$('.sdimg').attr("index", "messageamend");
					$('#article_work').css('display', 'none');
					$('#student_data').css('display', 'none');
					user = "admin";
					
					$.session.set("home_path","messageamend");
				} else if(flag == "cAdmin") {
					$('#student').css('display', 'none');
					$('#teacher').css('display', 'none');
					$('#admin').css('display', 'none');
					$('#cAdmin').css('display', 'block');
					
					$('.sdimg').attr("index", "cAdminCompany");
					$('#article_work').css('display', 'none');
					$('#student_data').css('display', 'none');
					user = "cAdmin";
					
					$.session.set("home_path","cAdminCompany");
				}

				if($.session.get("home_path") == null || $.session.get("home_path") == "") {
					$('.center').html('');
					$('.center').load('./message.html');
				} else {
					$('.center').html('');

					$('.nav li').removeClass('active')
					var li_id = "li[index='" + $.session.get("home_path") + "']";
					$(li_id).addClass('active');

					//加载内容
					$('.center').load("./" + $.session.get("home_path") + ".html");
					//加载完毕清空
					$.session.set("home_path", "")
				}
			});

			//0为自己的文章，-1为全部的文章
			$('#article_full').click(function() {
				$.session.set("a_flag", -1);
			})

			$('#article_my').click(function() {
				$.session.set("a_flag", 0);
			})

			$('#student_data').click(function() {
				$.session.set("sno_flag", 0); //-1代表非登录用户，0代表登录用户
			})

			$('.sdimg').click(function() {
				$.session.set("sno_flag", 0); //-1代表非登录用户，0代表登录用户
			})

			$('.nav li').click(function() {
				$('.center').html('');
				$('.nav li').removeClass('active')
				$(this).addClass('active')
				if(!$(this).attr('index') == "" || !$(this).attr('index') == null) {
					$('.center').load('./' + $(this).attr('index') + '.html');
				}
				$.session.set("page", 1);
			})

			//退出
			$('#loginout1').click(function() {
				$.ajax({
					xhrFields: {
						withCredentials: true
					},
					type: "GET",
					url: getFullURL("logout"),
					data: {},
					dataType: "json",
					success: function(data) {
						if(data.status == 0) {
							$.session.remove("shenfen");
							$.session.remove("sno");
							$.session.remove("tno");
							window.location.href = "./login.html";
						}
					},
					error: function(err) {
						alert("请求异常，请重新登录！", function() {
							$(location).attr('href', './login.html');
						})
					}
				})
			})

			//头像初始化ajax
			$(function() {
				var flag = $.session.get("shenfen");

				var urlPath = getSourceURL() + user + ".jpg";

				isRunUrl(urlPath).then(function(data) {
					$('#img_src').attr("src", urlPath);
					console.clear();
				}, function(data) {
					console.clear();
					if(flag == "user") {
						$('#img_src').attr("src", "./img/student.jpg");
					} else if(flag == "teacher") {
						$('#img_src').attr("src", "./img/teacher.jpg");
					} else if(flag == "admin") {
						$('#img_src').attr("src", "./img/admin.jpg");
					} else if(flag == "cAdmin") {
						$('#img_src').attr("src", "./img/cAdmin.jpg");
					}
				})
			})

			//文章的ajax
			$.ajax({
				xhrFields: {
					withCredentials: true
				},
				type: 'GET',
				url: getFullURL("get-articles"),
				data: {
					pageNum: 1,
					pageSize: 10
				},
				success: function(data) {
					if(data.status == 0) {
						console.log(data);
						var list = data.page.list;
						$('#hotTOP10').html("");
						for(var i = 0; i < list.length; i++) {
							var str = `
		                       <li class="hotTOP10-ul-li" id="li_` + list[i].arid + `">
		                            <h5 class="hotTOP10-ul-li-h5">` + list[i].title + `</h5>
		                            <h6 class="hotTOP10-ul-li-h6">` + list[i].content + `</h6>
		                            <span class="hotTOP10-ul-li-span">★&nbsp;` + list[i].dianzan + `</span>
		                            <input type="hidden" id="arid" value='` + list[i].arid + `'/>
		                        </li>
	                       `;
							var div = $('<div></div>');
							div.html(str);
							$('#hotTOP10').append(div);

							var li_id = "#li_" + list[i].arid;
							$(li_id).click(function() {
								$('.nav li').removeClass('active')
								$('#article_full').addClass('active')
								$('#collapseTwo').addClass('in')
								$.session.set("arid", $(this).children("input").eq(0).val());
								$('.center').html('');
								$('.center').load('./article.html');
							})
						}
					}
				},
				error: function(err) {
					alert("请求异常，请重新登录！", function() {
						$(location).attr('href', './login.html');
					})
				}
			})
		</script>
	</body>

</html>